/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cxhd.pacs.actor;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.actor.UntypedActorFactory;
import akka.routing.RoundRobinPool;
import akka.routing.RoundRobinRouter;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Administrator
 */
public class ActorManager {

    private static ActorManager actorManager;
    private Map<String, ActorRef> actors = new HashMap<String, ActorRef>();

    private ActorSystem system = ActorSystem.create("myActor");

    public static ActorManager getIntance() {
        if (actorManager == null) {
            actorManager = new ActorManager();

        }

        return actorManager;
    }

    public void initActor() {

        ActorRef savePatInfoActor = system.actorOf(Props.create(SavePatInfoActor.class), "savePatInfoActor");
        ActorRef startDicomExeActor = system.actorOf(Props.create(StartDicomExeActor.class), "startDicomExeActor");
        ActorRef dicomToJpgActor = system.actorOf(Props.create(DicomToJpgActor.class), "dicomToJpgActor");
        ActorRef pdfToJpgActor = system.actorOf(Props.create(PdfToJpgActor.class), "pdfToJpgActor");
         ActorRef sendSmsActor = system.actorOf(Props.create(SendSmsActor.class), "sendSmsActor");

        actors.put("savePatInfoActor", savePatInfoActor);
        actors.put("startDicomExeActor", startDicomExeActor);
        actors.put("dicomToJpgActor", dicomToJpgActor);
        actors.put("pdfToJpgActor", pdfToJpgActor);
        actors.put("sendSmsActor", sendSmsActor);

    }

    public ActorRef getActor(String actorName) {
        return actors.get(actorName);
    }

    public void destory() {
        for (String key : actors.keySet()) {

        }
        System.out.println("关闭akka");
        system.shutdown();

    }

}
